function request(url, data = {}, type = 'get') {
  return new Promise(resolve => {
    $.ajax({
      url,
      data,
      type,
      dataType: 'json',
      success: data => {
        resolve(data);
      }
    })
  })
}


export const APILogin = data => request('http://localhost/7.20/denglu.php', data);
export const APIRegister = data => request('http://localhost/7.20/yonghu.php', data);
export const APIGoodsList = data => request('http://localhost/7.27/goods-list.php', data);
export const APIGoodsDetail = data => request('http://localhost/7.27/goods-detail.php', data);
export const APIAddCart = data => request('http://localhost/7.27/cart-add.php', data);
export const APICartList = data => request('http://localhost/7.27/cart-list.php', data);
export const APICartUpdate = data => request('http://localhost/7.27/cart-update.php', data);
export const APICartDelete = data => request('http://localhost/7.27/cart-delete.php', data);
